package info.tsukaworld.actor;

public class AnimatedActor extends MovingActor
{
    String[][] animations;   
    int currentImage;
    int animationTimer;
    
    public AnimatedActor()
    {
        super("RobotUp2.gif");
        animations = setAnimations();
        setAnimations();
        currentImage = 0;
        animationTimer = 0;
    }
    
    public AnimatedActor(String[][] an)
    {
        super("RobotUp2.gif");
        animations = an;
        setAnimations();
        currentImage = 0;
        animationTimer = 0;
    }
    
    public void act()
    {
        currentImage %= animations[0].length;
        if( !isMoving() )
            currentImage = 0;
        setImageFilename( animations[ getDirection() / 90 ][ currentImage ] );
        if( getCurrentMove() != 0 && (getCurrentMove() % (getMoveSpeed() / animations[ getDirection() / 90 ].length )) == 0)
            currentImage++;
        super.act();
    }
    
    public String[][] setAnimations()
    {
        String[][] temp = new String[4][4];
        //Up animations
        temp[0][0] = "RobotUp1.gif";
        temp[0][1] = "RobotUp2.gif";
        temp[0][2] = "RobotUp3.gif";
        temp[0][3] = "RobotUp2.gif";
        //Right animations
        temp[1][0] = "RobotRight1.gif";
        temp[1][1] = "RobotRight2.gif";
        temp[1][2] = "RobotRight3.gif";
        temp[1][3] = "RobotRight2.gif";
        //Down animations
        temp[2][0] = "RobotDown1.gif";
        temp[2][1] = "RobotDown2.gif";
        temp[2][2] = "RobotDown3.gif";
        temp[2][3] = "RobotDown2.gif";
        //Left animations
        temp[3][0] = "RobotLeft1.gif";
        temp[3][1] = "RobotLeft2.gif";
        temp[3][2] = "RobotLeft3.gif";
        temp[3][3] = "RobotLeft2.gif";
        return temp;
    }
}